package com.classes.constants.logic;

import java.nio.ByteBuffer;

public class Constants_field_ref_info extends ConstantsAbstract {
    private short classInfoIndex;
    private short nameAndTypeIndex;

    public Constants_field_ref_info(byte tag) {
        super(tag);
    }

    @Override
    public void parse(ByteBuffer buffer) {
        classInfoIndex = buffer.getShort();
        nameAndTypeIndex = buffer.getShort();
    }


    @Override
    public String toString() {
        return "tag=" + tag + " classInfoIndex=" + classInfoIndex + " nameAndTypeIndex=" + nameAndTypeIndex;
    }

    @Override
    public String getContent() {
        for (int i = 1; i <= contants_pool.size(); i++) {
            if (i == classInfoIndex) {
                return contants_pool.get(i - 1).getContent();
            }
        }
        return null;
    }


}
